package com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.repo

import android.util.Log
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.lancoo.cpbase.authentication.base.CurrentUser
import com.lancoo.znbkxx.teacher.Ext
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.Constants
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.*
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.remote.BaseData
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.remote.MarkService
import com.lancoo.znbkxx.teacher.utils.LogUtil
import io.reactivex.Single
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import org.json.JSONObject
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.set

/**
 * Created by Dadong on 2020/7/7
 * Describe:
 */
class MarkRepo constructor(private val remote: MarkService) {

    /*
    * 获取试卷预览(答题卡+试题详情)
    * */
    fun getPaperPreviewInfor(
            paperId: String,
            setId: String
    ): Single<BaseData<PaperPreviewInfor>> {
        val params = Constants.createParamas()
        params["PaperID"] = paperId
        params["SetID"] = setId
        return remote.getPaperPreviewInfor(params)
    }


    /*
    * 获取某个学生试卷分析(答题卡)
    * */
    fun getPaperAnalysisInfor(
            stuId: String,
            paperId: String,
            setId:String
    ): Single<BaseData<PaperPerAnalysisInfor>> {
        val params = Constants.createParamas()
        params["StuID"] = stuId
        params["PaperID"] = paperId
        params["SetID"] = setId
        return remote.getPaperAnalysisInfor(params)
    }

    /*
    * 获取当前学生认知等级
    * */
    fun getCognitiveGrade(
            stuId:String,
            paperId: String,
            zsdArea:String
    ): Single<BaseData<PaperAnalysisDiagnosisInfor>> {
        val paramas = Constants.createParamas()
//        paramas["Token"] = CurrentUser.getToken()
//        paramas["StageNo"] = Ext.STAGE_NO
//        paramas["SchoolID"] = CurrentUser.getSchoolID()//校内ID
//        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["StuID"] = stuId
        paramas["PaperID"] = paperId
        paramas["ZsdArea"] = zsdArea
        return remote.getCognitiveGrade(paramas)
    }

    /*
    * 获取试卷讲评(答题卡+整体详情)
    * */
    fun getPaperEvaluationInfor(
            paperId: String,
            setId:String
    ): Single<BaseData<PaperEvaluationInfor>> {
        val params = Constants.createParamas()
        params["PaperID"] = paperId
        params["SetID"] = setId
        return remote.getPaperEvaluationInfor(params)
    }

    /*
    * 获取试卷讲评(单题详情)
    * */
    fun getQuesEvaluationDeatil(
            paperId: String,
            quesId: String,
            startIndex: Int
    ): Single<BaseData<QuesEvaluationDetail>> {
        val params = Constants.createParamas()
        params["PaperID"] = paperId
        params["QuesID"] = quesId
        params["StartIndex"] = startIndex
        return remote.getQuesEvaluationDeatil(params)
    }

    /*
    * 获取纠错类型
    * */
    fun getErrorConfig(): Single<BaseData<List<ErrorRecovery>>> {
        val params = Constants.createParamas()
        return remote.getErrorConfig(params)
    }

    /*
    * 提交纠错信息
    * */
    fun addQuesErrorCorrection(
            quesId: String,
            errorType: String,
            errorDescribe: String
    ): Single<BaseData<String>> {

        val jSONObject: JSONObject? = Constants.createJSONObject()
        jSONObject!!.put("CourseClassID", Ext.COURSE_CLASSID)
        jSONObject!!.put("QuesID", quesId)
        jSONObject!!.put("ErrorType", errorType)
        jSONObject!!.put("ErrorDescribe", errorDescribe)

        val objectX = Gson().fromJson(jSONObject.toString(), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========提交纠错信息请求参数========" + BODY)
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.addQuesErrorCorrection(CurrentUser.getToken(), CurrentUser.getUserID(), body)
    }

    /*
    * 导出讲评信息
    * */
    fun exportComment(
            paperId: String,
            setId: String,
            isAnswerAnalysis: Boolean,
            isZsd: Boolean,
            isListenVideo: Boolean,
            isListenText: Boolean
    ): Single<BaseData<String>> {
        val params = Constants.createParamas()
        params["PaperID"] = paperId
        params["SetID"] = setId
        params["IsExportJX"] = isAnswerAnalysis
        params["IsExportZSD"] = isZsd
        params["IsExportListenAudio"] = isListenVideo
        params["IsExportListenText"] = isListenText
        return remote.exportComment(params)
    }

    /*
    * 组卷主页面获取试卷名称与PaperID
    * */
    fun getPaperInit(
            stuId: String,
            layer: Int
    ): Single<BaseData<TempletPaperInit>> {
        val params = Constants.ParamasOne()
        params["StuID"] = stuId
        params["OuterSchoolID"] = CurrentUser.getSchoolID()//校外ID
        params["Layer"] = layer
        return remote.getPaperInit(params)
    }

    /*
    * 获取试卷生词率等级配置信息
    * */
    fun getExceedList(): Single<BaseData<TempletExceedList>> {
        val params = Constants.ParamasOne()
        return remote.getExceedList(params)
    }

    /*
   * 获取语法专项的专题列表
   * */
    fun getTopicList(
            stuId: String
    ): Single<BaseData<TempletGrammarSpecificListInfor>> {

        val jSONObject: JSONObject? = Constants.createJSONObjectOne()
        jSONObject!!.put("StuID", stuId)
        jSONObject!!.put("SchoolID", Ext.SCHOOLID)//校内ID
        jSONObject!!.put("IsSingleSubShow",true)//是否显示单个子专题，true-显示，false-不显示

        val objectX = Gson().fromJson(jSONObject.toString(), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取语法专项的专题列表请求参数========$BODY")
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getTopicList(CurrentUser.getToken(), CurrentUser.getUserID(), body)
    }

    /*
  * 获取专题的知识点信息（支持多个专题同时查询）
  * */
    fun getTopicKlg(
            stuId: String,
            topicIds:String
    ): Single<BaseData<TopicGrammarKlgInfor>> {

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["StuID"] = stuId
        paramas["SchoolID"] = Ext.SCHOOLID//校内ID
        paramas["TopicIds"] = topicIds

        val objectX = Gson().fromJson(Gson().toJson(paramas), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取语法专题的知识点信息========$BODY")
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getTopicKlg(CurrentUser.getToken(), CurrentUser.getUserID(), body)
    }

    /*
    * 获取模板列表信息，用于模板管理
    * */
    fun getTempletBriefList(
            templetType: Int
    ): Single<BaseData<TempletPaperListInfor>> {

        val jSONObject: JSONObject? = Constants.createJSONObjectOne()
        jSONObject!!.put("ProvinceID", Ext.PROVINCE_ID)
        jSONObject!!.put("CityID", Ext.CITY_ID)
        jSONObject!!.put("CountyID", CurrentUser.getCountyID())
        jSONObject!!.put("TempletType", templetType)

        val objectX = Gson().fromJson(jSONObject.toString(), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取模板列表信息请求参数========" + BODY)
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getTempletBriefList(CurrentUser.getToken(), CurrentUser.getUserID(), body)
    }

    /*
    * 获取模板管理的选中模板的题型信息
    * */
    fun getTempletTypeList(
            templetId: String
    ): Single<BaseData<TemplateTypeListInfor>> {
        val params = Constants.ParamasOne()
        params["TempletID"] = templetId
        return remote.getTempletTypeList(params)
    }

    /*
     * 获取自定义模板适用题型
     * */
    fun getSelectedTypeList(
            templetType: Int
    ): Single<BaseData<TempletSelectedTypeListInfor>> {

        val jSONObject: JSONObject? = Constants.createJSONObjectOne()
        jSONObject!!.put("ProvinceID", Ext.PROVINCE_ID)
        jSONObject!!.put("CityID", Ext.CITY_ID)
        jSONObject!!.put("CountyID", CurrentUser.getCountyID())
        jSONObject!!.put("TempletType", templetType)

        val objectX = Gson().fromJson(jSONObject.toString(), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取自定义模板适用题型========" + BODY)
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getSelectedTypeList(CurrentUser.getToken(), CurrentUser.getUserID(), body)
    }

    /*
    * 保存自定义模板
    * */
    fun saveCustomizeTemplet(
            strCustomtemplet: String
    ): Single<BaseData<String>> {

        val objectX = Gson().fromJson(strCustomtemplet, JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取自定义模板适用题型========" + BODY)
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.saveCustomizeTemplet(CurrentUser.getToken(), CurrentUser.getUserID(), body)
    }


    /*
   *删除自定义模板
    */
    fun delCustomizeTemplet(
            templetId: String
    ): Single<BaseData<String>> {
        val params = Constants.ParamasOne()
        params["TempletID"] = templetId
        return remote.delCustomizeTemplet(params)
    }

    /*
    * 发起组卷
    * */
    fun startSelected(
            paperId: String,
            stuId: String,
            level: Int,
            layer: Int,
            templetId: String,
            langId:String,
            topicIds:String,
            paperName:String
    ): Single<BaseData<String>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.getToken()
        paramas["SubjectID"] = "C"
        paramas["StageNo"] = Ext.STAGE_NO
        paramas["UserID"] = CurrentUser.getUserID()
        paramas["SchoolID"] = CurrentUser.getSchoolID()//培训机构ID(校外ID)
        paramas["InnerSchoolID"] = Ext.SCHOOLID//校内ID
        paramas["PaperID"] = paperId
        paramas["StuID"] = stuId
        paramas["ProvinceID"] = Ext.PROVINCE_ID
        paramas["CityID"] = Ext.CITY_ID
        paramas["CountyID"] = CurrentUser.getCountyID()
        paramas["Level"] = level
        paramas["Layer"] = layer
        paramas["TempletID"] = templetId
        paramas["LangID"] = langId
        paramas["TopicIDs"] = topicIds
        paramas["PaperName"] = paperName
        return remote.startSelected(paramas)
    }

    /*
  * 获取组卷抽题进度
  * */
    fun getSelectedProgress(
            paperId: String,
            stuId: String,
            layer: Int,
            templetId: String
    ): Single<BaseData<String>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.getToken()
        paramas["UserID"] = CurrentUser.getUserID()
        paramas["SchoolID"] = CurrentUser.getSchoolID()//培训机构ID(校外ID)
        paramas["PaperID"] = paperId
        paramas["StuID"] = stuId
        paramas["Layer"] = layer
        paramas["TempletID"] = templetId
        return remote.getSelectedProgress(paramas)
    }

    /*
     * 生成试卷（抽题结束后，调用接口，生成试卷结构信息）
     * */
    fun generatePaper(
            paperId: String,
            paperName:String,
            stuId: String,
            layer: Int,
            templetId: String
    ): Single<BaseData<String>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["PaperID"] = paperId
        paramas["PaperName"] = paperName
        paramas["StuID"] = stuId
        paramas["Layer"] = layer
        paramas["TempletID"] = templetId
        paramas["SchoolID"] = CurrentUser.SchoolID//校外ID
        return remote.generatePaper(paramas)
    }

    /*
   * 发布试卷
   * */
    fun publishPaper(
            paperId: String,
            stuId: String,
            layer: Int
    ): Single<BaseData<Boolean>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["PaperID"] = paperId
        paramas["StuID"] = stuId
        paramas["Layer"] = layer
        paramas["InnerSchoolID"] = Ext.SCHOOLID//校内ID
        paramas["SchoolID"] = CurrentUser.SchoolID//校外ID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["GlobalGrade"] = Ext.GLOBAL_GRADE_STU
        return remote.publishPaper(paramas)
    }

    /*
    * 删除未发布的试卷
    * */
    fun delPaper(
            paperId: String,
            stuId: String,
            layer: Int
    ): Single<BaseData<Boolean>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["PaperID"] = paperId
        paramas["StuID"] = stuId
        paramas["Layer"] = layer
        paramas["SchoolID"] = CurrentUser.SchoolID//校外ID
        return remote.delPaper(paramas)
    }

    /*
   * 获取语言能力专项列表信息
   * */
    fun getAllAbilityBaseInfo(
            stuId: String
    ): Single<BaseData<TempletLanguageSpecificListInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["SchoolID"] = Ext.SCHOOLID//校内ID
        paramas["StuID"] = stuId
        paramas["StageNo"] = Ext.STAGE_NO
        paramas["ProvinceID"] = CurrentUser.ProvinceID
        paramas["CityID"] = CurrentUser.CityID
        paramas["CountyID"] = CurrentUser.CountyID


        return remote.getAllAbilityBaseInfo(paramas)
    }

    /*
  * 获取语言能力知识点信息
  * */
    fun getLangKlgList(
            stuId:String,
            langId: String
    ): Single<BaseData<TopicLanguageKlgInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["StuID"] = stuId
        paramas["LangID"] = langId
        paramas["SchoolID"] = Ext.SCHOOLID//校内ID
        paramas["StageNo"] = Ext.STAGE_NO
        paramas["ProvinceID"] = CurrentUser.ProvinceID
        paramas["CityID"] = CurrentUser.CityID
        paramas["CountyID"] = CurrentUser.CountyID

        val objectX = Gson().fromJson(Gson().toJson(paramas), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取语法专题的知识点信息========$BODY")
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getLangKlgList(CurrentUser.Token, CurrentUser.UserID, body)
    }


    /*
      * 获取组卷生成待审核试卷内容(非口语)
      * */
    fun getReviewPaperInfo_1v1(
            paperId: String,
            stuId:String
    ): Single<BaseData<TestPaperReviewInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }
        val Map = JSONObject()
        Map.put("SchoolID",CurrentUser.SchoolID)//校外ID
        Map.put("PaperID", paperId)
        Map.put("StageNo", Ext.STAGE_NO )
        Map.put("SubjectID", "C")
        Map.put("IsReplace", true)
        Map.put("StuID", stuId)
        Map.put("InnerSchoolID", Ext.SCHOOLID)//校内ID

        val objectX = Gson().fromJson(Map.toString(), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        Log.e("jSONObject", "========获取待审核试卷请求入参========$BODY")
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getReviewPaperInfo_1v1(CurrentUser.Token, CurrentUser.UserID, body)
    }

    /*
    * (一对一）：试卷预览
    * */
    fun getPreviewPaperInfo_1v1(
            paperId:String,
            setId:String
    ): Single<BaseData<PaperPreviewInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }

        val previewParmas: MutableMap<String, Any> = HashMap()
        previewParmas["SchoolID"] = CurrentUser.SchoolID//校外ID
        previewParmas["PaperID"] = paperId
        previewParmas["SetID"] = setId
        previewParmas["StageNo"] = Ext.STAGE_NO
        previewParmas["SubjectID"] = "C"
        previewParmas["IsReplace"] = true

        val objectX = Gson().fromJson(Gson().toJson(previewParmas), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        LogUtil.e("jSONObject", "=====获取可替换试题请求入参======$BODY")
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getPreviewPaperInfo_1v1(CurrentUser.Token, CurrentUser.UserID, body)
    }

    /*
   *(一对一）查看成绩分析
   * */
    fun getPaperAnalysisInfor_1v1(
            paperId: String
    ): Single<BaseData<PaperPerAnalysisInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["TID"] = CurrentUser.UserID
        paramas["PaperID"] = paperId
        paramas["OutsideSchoolID"] = CurrentUser.SchoolID//校外ID
        paramas["StageNo"] = Ext.STAGE_NO
        paramas["SubjectID"] = "C"
        paramas["StartIndex"] = 1
        paramas["IsSerial"] = true
        paramas["IsReplace"] = true


        return remote.getPaperAnalysisInfor_1v1(paramas)
    }


    /*
   * （一对一）获取普通替换试题
   * */
    fun getReplaceQuesInfo_1v1(
            stuId:String,
            typeNo:String,
            genreId:Int,
            specialFeature: String,
            itemNum:Int,
            mFilterID:String,
            sFilterID:String,
            importKlgList:ArrayList<String>,
            mainKlgList:ArrayList<String>,
            themeKlgList: ArrayList<String>,
            isTheme:Boolean,
            startIndex:Int
    ): Single<BaseData<TestPaperReplaceQuesInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE_STU == "K7"||Ext.GLOBAL_GRADE_STU == "K8"||Ext.GLOBAL_GRADE_STU == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE_STU == "K10"||Ext.GLOBAL_GRADE_STU == "K11"||Ext.GLOBAL_GRADE_STU == "K12"){
            Ext.STAGE_NO = "C"
        }

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID//校外ID
        paramas["InnerSchoolID"] = Ext.SCHOOLID//校内ID
        paramas["StuID"] = stuId
        paramas["SubjectID"] = "C"
        paramas["StageNo"] = Ext.STAGE_NO
        paramas["TypeNo"] = typeNo
        paramas["GenreID"] = genreId
        paramas["ProvinceID"] = CurrentUser.ProvinceID
        paramas["CityID"] = CurrentUser.CityID
        paramas["CountyID"] = CurrentUser.CountyID
        paramas["SpecialFeature"] = specialFeature//提示类型
        paramas["ItemNum"] = itemNum//小题数
        paramas["MFilterID"] = mFilterID//必须过滤的试题，多个以“|”分隔
        paramas["SFilterID"] = sFilterID//可选过滤的试题，已经替换出来，用户尚未选择的试题，多个以“|”分隔
        paramas["ImportKnList"] = importKlgList
        paramas["MainList"] = mainKlgList
        paramas["ThemeList"] = themeKlgList
        paramas["IsTheme"] = isTheme//是否主题抽题，true-主题抽题，false-非主题抽题
        paramas["StartIndex"] = startIndex//试题的小题起始下标，默认从1开始


        val objectX = Gson().fromJson(Gson().toJson(paramas), JsonObject::class.java)
        val BODY = Gson().toJson(objectX)
        LogUtil.e("jSONObject", "=====获取可替换试题请求入参======$BODY")
        val body = RequestBody.create("application/json; charset=utf-8".toMediaTypeOrNull(), BODY)
        return remote.getReplaceQuesInfo_1v1(CurrentUser.Token, CurrentUser.UserID, body)
    }

    /*
  * 保存替换的试题
  * */
    fun saveReplacedQues(
            quesId: String,
            originalQuesId:String,
            paperId: String,
            paperType: Int
    ): Single<BaseData<Boolean>> {

        val paramas = Constants.createParamas()
//        paramas["Token"] = CurrentUser.Token
//        paramas["UserID"] = CurrentUser.UserID
//        paramas["SchoolID"] = CurrentUser.SchoolID//校外ID
        paramas["QuesID"] = quesId//替换的试题ID
        paramas["OriginalQuesID"] = originalQuesId//原题ID
        paramas["PaperID"] = paperId//试卷ID
        paramas["PaperType"] = paperType//试卷类型
        return remote.saveReplacedQues(paramas)
    }

    /*
    * （一对一）获取主题知识点相关信息
    * */
    fun getTypeThemeList(
            typeNo: String,
            genreId: Int
    ): Single<BaseData<TypeThemeInfor>> {

        if(Ext.GLOBAL_GRADE_STU == "K6" ||Ext.GLOBAL_GRADE == "K7"||Ext.GLOBAL_GRADE == "K8"||Ext.GLOBAL_GRADE == "K9"){
            Ext.STAGE_NO = "B"
        }else if(Ext.GLOBAL_GRADE == "K10"||Ext.GLOBAL_GRADE == "K11"||Ext.GLOBAL_GRADE == "K12"){
            Ext.STAGE_NO = "C"
        }

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["StageNo"] = Ext.STAGE_NO
        paramas["TypeNo"] = typeNo
        paramas["GenreID"] = genreId
        return remote.getTypeThemeList(paramas)
    }

    /*
    * 获取唯一码对应的数字化编码
    * */
    fun getKlgCode(
            uniqueCode: String
    ): Single<BaseData<String>> {

        val params = Constants.createParamas()
        params["UniqueCode"] = uniqueCode
        return remote.getKlgCode(params)
    }

    /*
    * 导出学生成绩
    * */
    fun exportPaperScore(
            paperId: String,
            setId:String
    ): Single<BaseData<String>> {

        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["UserID"] = CurrentUser.UserID
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["PaperID"] = paperId
        paramas["SetID"] = setId
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["CourseClassName"] = Ext.COURSE_CLASSNAME
        return remote.exportPaperScore(paramas)
    }

    /*
  * 改变音频播放速度
  * */
    fun adjustAudioSpeed(
            audioSpeed:Double,
            paperId: String,
            quesId:String
    ): Single<BaseData<String>> {

        val paramas: MutableMap<String, Any> = HashMap()

        paramas["Token"] = CurrentUser.Token
        paramas["SubjectID"] = "C"
        paramas["UserID"] = CurrentUser.UserID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["GlobalGrade"] = Ext.GLOBAL_GRADE
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["PaperID"] = paperId
        paramas["QuesID"] = quesId
        paramas["AudioSpeed"] = audioSpeed
        return remote.adjustAudioSpeed(paramas)
    }

    /*
  * 是否开启班级认知诊断
  * */
    fun getIsOpenClassRZZD_App(): Single<BaseData<Boolean>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getIsOpenClassRZZD_App(paramas)
    }

    /*
    * 是否切换到个人认知诊断
    * */
    fun getIsChangeStu_App(): Single<BaseData<String>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["Token"] = CurrentUser.Token
        paramas["TID"] = CurrentUser.UserID
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getIsChangeStu_App(paramas)
    }

    /*
    * 获取班级知识点域
    * */
    fun getZsdArea_App(): Single<BaseData<ClassKnowledgeAreaInfor>> {

        val paramas = Constants.createParamas()
//        paramas["Stage"] = Ext.STAGE_NO
//        paramas["SchoolID"] = CurrentUser.SchoolID
//        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getZsdArea_App(paramas)
    }


    /*
    * 班级预估成绩
    * */
    fun getClassTotalScore_App(): Single<BaseData<ClassEstimateGradeInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getClassTotalScore_App(paramas)
    }

    /*
   * 获取认知指数主页面详情
   * */
    fun getClassCognitiveIndex_App(zsdArea:String): Single<BaseData<ClassCognitiveDiagnosisInfor>> {

        val paramas = Constants.createParamas()
//        paramas["SchoolID"] = CurrentUser.SchoolID
//        paramas["CourseClassID"] = Ext.COURSE_CLASSID
//        paramas["StageNo"] = Ext.STAGE_NO
        paramas["ZsdArea"] = zsdArea
        return remote.getClassCognitiveIndex_App(paramas)
    }

    /*
    * 班级学生成绩得分分布图弹窗
    * */
    fun getScoreDistre_App(flag:Int): Single<BaseData<ClassStuGradeDistributionInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["Flag"] = flag
        return remote.getScoreDistre_App(paramas)
    }

    /*
    * 总评成绩学生进步/退步人数弹窗
    * */
    fun getStuNum_App(): Single<BaseData<ClassStuNumUpDownInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getStuNum_App(paramas)
    }

    /*
    *班级认知指数区域分布表-弹窗
    * */
    fun getRangeClassTableInfo_App(flag:Int,zsdArea:String): Single<BaseData<ClassStuCognitiveDiagnosisInfor>> {

        val paramas = Constants.createParamas()
//        paramas["SchoolID"] = CurrentUser.SchoolID
//        paramas["CourseClassID"] = Ext.COURSE_CLASSID
//        paramas["StageNo"] = Ext.STAGE_NO
        paramas["Flag"] = flag
        paramas["ZsdArea"] = zsdArea
        return remote.getRangeClassTableInfo_App(paramas)
    }

    /*
    * 班级认知荣誉榜
    * */
    fun getCognitiveIndexHonorRank_App(zsdArea:String): Single<BaseData<ClassStuCognitiveHonorRollListInfor>> {

        val paramas = Constants.createParamas()
//        paramas["Token"] = CurrentUser.Token
//        paramas["SchoolID"] = CurrentUser.SchoolID
//        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["ZsdArea"] = zsdArea
//        paramas["StageNo"] = Ext.STAGE_NO
        return remote.getCognitiveIndexHonorRank_App(paramas)
    }

    /*
    *词汇认知主页面
    * */
    fun getClassVocablary_App(zsdArea:String): Single<BaseData<ClassVocablaryDiagnosisInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["ZsdArea"] = zsdArea
        return remote.getClassVocablary_App(paramas)
    }

    /*
   * 词汇量区域分布表-弹窗
   * */
    fun getRangeClassVocabInfo_App(flag:Int,typeStr:String,zsdArea:String): Single<BaseData<ClassVocabularyMasterDistribInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["Flag"] = flag
        paramas["TypeStr"] = typeStr
        paramas["ZsdArea"] = zsdArea
        return remote.getRangeClassVocabInfo_App(paramas)
    }

    /*
   *语法认知主页面
   * */
    fun getClassGrammar_App(zsdArea:String): Single<BaseData<ClassGrammarDiagnosisInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["ZsdArea"] = zsdArea
        return remote.getClassGrammar_App(paramas)
    }

    /*
   * 语法量区域分布表-弹窗
   * */
    fun getRangeClassGrammarInfo_App(flag:Int,zsdArea:String): Single<BaseData<ClassGrammarMasterDistribInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["Flag"] = flag
        paramas["ZsdArea"] = zsdArea
        return remote.getRangeClassGrammarInfo_App(paramas)
    }

    /*
  * 语言能力认知
  * */
    fun getLanguageForClass_App(): Single<BaseData<ClassLanguageAbilityInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getLanguageForClass_App(paramas)
    }


    /*
    * 语言能力认知情况弹窗
    * */
    fun getAbilityForClass_App(abilityName:String): Single<BaseData<ClassStuLanguageAbilityInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["AblilityName"] = abilityName
        return remote.getAbilityForClass_App(paramas)
    }

    /*
    * 做题特点主界面
    * */
    fun getClassExerciseTrait_App(): Single<BaseData<ClassAnswertraitInfor>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        return remote.getClassExerciseTrait_App(paramas)
    }

    /*
  * 学习特点主界面
  * */
    fun getStudyFeatureForClass_App(): Single<BaseData<ClassStudyFeature>> {
        val paramas: MutableMap<String, Any> = HashMap()
        paramas["SchoolID"] = CurrentUser.SchoolID
        paramas["CourseClassID"] = Ext.COURSE_CLASSID
        paramas["GlobalGrade"] = Ext.GLOBAL_GRADE
        return remote.getStudyFeatureForClass_App(paramas)
    }

    /*
    * 移动端班级学习建议
    * */
    fun getClassStudyAdvice_App(zsdArea:String): Single<BaseData<ClassStudyAdviceInfor>> {

        val paramas = Constants.createParamas()
//        paramas["Token"] = CurrentUser.Token
//        paramas["TID"] = CurrentUser.UserID
//        paramas["SchoolID"] = CurrentUser.SchoolID
//        paramas["CourseClassID"] = Ext.COURSE_CLASSID
//        paramas["GlobalGrade"] = Ext.GLOBAL_GRADE
        paramas["ZsdArea"] = zsdArea
//        paramas["StageNo"] = Ext.STAGE_NO
        paramas["ProvinceID"] = CurrentUser.ProvinceID
        paramas["CityID"] = CurrentUser.CityID
        return remote.getClassStudyAdvice_App(paramas)
    }

}